package com.s06.h01.model;

import java.text.SimpleDateFormat;
import java.util.Date;

public class User {

	private String surname;
	private Date dob;
	private Date createDate;// - date when user is created (in parse method)
	private Date updateDate;// - when users got updated with capital letters
	private String name;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurname() {
		return surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public Date getDob() {
		return dob;
	}

	public void setDob(Date dob) {
		this.dob = dob;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public void greetYourself(Date dateCurrent) { // instance method
		
		
		System.out.println("Hello " + name + " " + surname + " you are "
				+ getAge(dob) + " old " + "Your account was created: "
				+ getCreationTime(createDate, dateCurrent) + " mil sec ago and updated "
				+ getUpdateTime(updateDate,dateCurrent));
	

	}

	private Long getCreationTime(Date createDate2, Date currentDate) {

		
		long createdAgo = currentDate.getTime() - createDate2.getTime();
		return createdAgo;
	}

	private Long getUpdateTime(Date updateDate2, Date dateCurrent) {

		
		long createdAgo = dateCurrent.getTime() - updateDate2.getTime();
		return createdAgo;
	}

	private Integer getAge(Date dob) {

		Date dateCurrent = new Date();
		// long age= dateCurrent.getTime()- dob.getTime();

		SimpleDateFormat sdf = new SimpleDateFormat();
		sdf.applyPattern("YYYY");
		String yearNow = sdf.format(dateCurrent);
		String yearBorn = sdf.format(dob);

		return (Integer.parseInt(yearNow) - Integer.parseInt(yearBorn));

	}

	public void makeNameToUpper() {
		name = name.toUpperCase();
		surname = surname.toUpperCase();

	}

}
